<template>
	<el-dialog v-model="visible" :close-on-click-modal='false' :close-on-press-escape='false' :fullscreen='true'>
		<el-tabs v-model="activeName" @tab-click="reloadDataList">
			<el-tab-pane label="出库明细" name="first">
				<OrderdetailTab :dataForm="dataForm" v-if="activeName === 'first' " ref="firstRef"></OrderdetailTab>
			</el-tab-pane>
			<el-tab-pane label="分配明细" name="second">
				<OrderdetaillistTab :dataForm="dataForm" v-if="activeName === 'second' " ref="secondRef"></OrderdetaillistTab>
			</el-tab-pane>
		</el-tabs>
	</el-dialog>
</template>

<script>
	import {
		ref,
		reactive,
		onMounted,
		nextTick, watch
	} from 'vue';
	import OrderdetailTab from "@/views/lswms/orders/OrderdetailTab.vue";
	import OrderdetaillistTab from "@/views/lswms/orders/OrderdetaillistTab.vue";
	//import {getCodeListByCode} from "@/network/lswms/base/Codelist.js"
	//import {hasPermission} from "@/utils/hasPermission"
	export default {
		name: "orderdetail",

		components: {
			OrderdetailTab,
			OrderdetaillistTab
		},

		setup() {
			const activeName = ref('first');

			const dataForm = ref({
				id: '',
				orderkey: ''
			})

			const visible = ref(false);
			const init = () => {
				visible.value = true;
				nextTick(function() {

					//  dataFormRef.value.resetFields();
					// roleIdListDefault.value = [];
					if (dataForm.value.orderkey) {
						dataForm.value.id = '';
						//   getDataList()
					}

				})
			}

			const firstRef = ref(null);
			const secondRef = ref(null);
			const reloadDataList = (tab, event) => {
				//console.log(tab)
				// let tabName = tab.name;
				// if (tabName == 'first') {
				// 	firstRef.init();
				// }
				// if (tabName == 'second') {
				// 	secondRef.init();
				// }
			}
			watch(dataForm.value,()=>{



				activeName.value = 'second' ;


				Promise.all(
						activeName.value = 'second'
				).then(function() {
					activeName.value = 'first' ;

				}).catch((err) => {
					{
						console.log(err);
					}
				})
			})
			return {
				activeName,
				dataForm,
				visible,
				init,
				reloadDataList,
				firstRef,
				secondRef
			}
		},

	}
</script>

<style scoped>

</style>
